package com.tvunetworks.device.extra.jms;

import com.tvunetworks.common.lang.service.route.bo.MqMessage;
import com.tvunetworks.common.lang.util.JacksonUtil;
import com.tvunetworks.common.service.mq.handler.MqMessageHandler;
import com.tvunetworks.device.extra.model.DeviceReport;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.MessageProperties;
import org.springframework.stereotype.Component;

/**
 * @author Ethan
 * @program:
 * @description:
 * @create: 2022/1/20 10:50
 **/
@Slf4j
@Component

public class JmsConsumer implements MqMessageHandler {

    @Override
    public String service() {
        return "device-extra";
    }

    @Override
    public String[] events() {
        return new String[]{"live.report"};
    }

    @Override
    public void onMessage(MqMessage message, MessageProperties mqProperties) throws Exception {
        String eventData = message.getEventData();
        log.error("收到的MQ 消息了..message: {}, eventData: {}", message, eventData);
        DeviceReport data = JacksonUtil.json2Bean(eventData, DeviceReport.class);
        System.out.println(data.toString());

    }
}
